package gui;

import java.awt.BorderLayout;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SpringLayout;

public class SamplePane extends AbstractViewPane {

	String name = "Exemple";
	
	ViewMode currentViewMode;
	
	public SamplePane(ViewMode v) {
		
		currentViewMode = v;
		
        String[] labels = {"Name: ", "Fax: ", "Email: ", "Address: ", "ABC: "};
        int numPairs = labels.length;

        //SampleBL sampleBL = SampleBL.getInstance();
        //name = sampleBL.getName();
        
        
        
        //Create and populate the panel.
        JPanel p = new JPanel(new SpringLayout());
        for (int i = 0; i < numPairs; i++) {
            JLabel l = new JLabel(labels[i], JLabel.TRAILING);
            p.add(l);
            JTextField textField = new JTextField("Bonjour");
            if (currentViewMode == ViewMode.CONSULTATION) {
            	textField.setEnabled(false);
            }
            l.setLabelFor(textField);
            p.add(textField);
        }

        //Lay out the panel.
        SpringUtilities.makeCompactGrid(p,
                                        numPairs, 2, //rows, cols
                                        6, 6,        //initX, initY
                                        6, 6);       //xPad, yPad
        
        add(p, BorderLayout.NORTH);
        
        if (currentViewMode != ViewMode.CONSULTATION) {
        	// Mode modification - afficher les boutons
	        JPanel commandBox = new JPanel();
	        commandBox.add(new JButton("Enregistrer"));
	        commandBox.add(new JButton("Annuler"));
	        drawCommandBox(commandBox);
        }
        

	}
	
	@Override
	public String getTitle() {
		// TODO Auto-generated method stub
		return "Panel";
	}

	@Override
	public boolean hasBeenModified() {
		return (currentViewMode != ViewMode.CONSULTATION);
	}

}
